home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / mx / binding / Watcher.as < prev   
Text File  |  2009-02-12  |  4KB  |  171 lines

  1. package mx.binding
  2. {
  3.    import mx.collections.errors.ItemPendingError;
  4.    import mx.core.mx_internal;
  5.    
  6.    use namespace mx_internal;
  7.    
  8.    public class Watcher
  9.    {
  10.       
  11.       mx_internal static const VERSION:String = "3.0.0.0";
  12.        
  13.       
  14.       protected var children:Array;
  15.       
  16.       public var value:Object;
  17.       
  18.       protected var cloneIndex:int;
  19.       
  20.       protected var listeners:Array;
  21.       
  22.       public function Watcher(param1:Array = null)
  23.       {
  24.          super();
  25.          this.listeners = param1;
  26.       }
  27.       
  28.       public function removeChildren(param1:int) : void
  29.       {
  30.          children.splice(param1);
  31.       }
  32.       
  33.       public function updateChildren() : void
  34.       {
  35.          var _loc1_:int = 0;
  36.          var _loc2_:int = 0;
  37.          if(children)
  38.          {
  39.             _loc1_ = children.length;
  40.             _loc2_ = 0;
  41.             while(_loc2_ < _loc1_)
  42.             {
  43.                children[_loc2_].updateParent(this);
  44.                _loc2_++;
  45.             }
  46.          }
  47.       }
  48.       
  49.       protected function shallowClone() : Watcher
  50.       {
  51.          return new Watcher();
  52.       }
  53.       
  54.       protected function wrapUpdate(param1:Function) : void
  55.       {
  56.          var wrappedFunction:Function = param1;
  57.          try
  58.          {
  59.             wrappedFunction.apply(this);
  60.          }
  61.          catch(itemPendingError:ItemPendingError)
  62.          {
  63.             value = null;
  64.          }
  65.          catch(rangeError:RangeError)
  66.          {
  67.             value = null;
  68.          }
  69.          catch(error:Error)
  70.          {
  71.             if(error.errorID != 1006 && error.errorID != 1009 && error.errorID != 1010 && error.errorID != 1055 && error.errorID != 1069)
  72.             {
  73.                throw error;
  74.             }
  75.          }
  76.       }
  77.       
  78.       private function valueChanged(param1:Object) : Boolean
  79.       {
  80.          if(param1 == null && value == null)
  81.          {
  82.             return false;
  83.          }
  84.          var _loc2_:* = typeof value;
  85.          if(_loc2_ == "string")
  86.          {
  87.             if(param1 == null && value == "")
  88.             {
  89.                return false;
  90.             }
  91.             return param1 != value;
  92.          }
  93.          if(_loc2_ == "number")
  94.          {
  95.             if(param1 == null && value == 0)
  96.             {
  97.                return false;
  98.             }
  99.             return param1 != value;
  100.          }
  101.          if(_loc2_ == "boolean")
  102.          {
  103.             if(param1 == null && value == false)
  104.             {
  105.                return false;
  106.             }
  107.             return param1 != value;
  108.          }
  109.          return true;
  110.       }
  111.       
  112.       public function notifyListeners(param1:Boolean) : void
  113.       {
  114.          var _loc2_:int = 0;
  115.          var _loc3_:int = 0;
  116.          if(listeners)
  117.          {
  118.             _loc2_ = listeners.length;
  119.             _loc3_ = 0;
  120.             while(_loc3_ < _loc2_)
  121.             {
  122.                listeners[_loc3_].watcherFired(param1,cloneIndex);
  123.                _loc3_++;
  124.             }
  125.          }
  126.       }
  127.       
  128.       protected function deepClone(param1:int) : Watcher
  129.       {
  130.          var _loc3_:int = 0;
  131.          var _loc4_:int = 0;
  132.          var _loc5_:Watcher = null;
  133.          var _loc2_:Watcher = shallowClone();
  134.          _loc2_.cloneIndex = param1;
  135.          if(listeners)
  136.          {
  137.             _loc2_.listeners = listeners.concat();
  138.          }
  139.          if(children)
  140.          {
  141.             _loc3_ = children.length;
  142.             _loc4_ = 0;
  143.             while(_loc4_ < _loc3_)
  144.             {
  145.                _loc5_ = children[_loc4_].deepClone(param1);
  146.                _loc2_.addChild(_loc5_);
  147.                _loc4_++;
  148.             }
  149.          }
  150.          return _loc2_;
  151.       }
  152.       
  153.       public function updateParent(param1:Object) : void
  154.       {
  155.       }
  156.       
  157.       public function addChild(param1:Watcher) : void
  158.       {
  159.          if(!children)
  160.          {
  161.             children = [param1];
  162.          }
  163.          else
  164.          {
  165.             children.push(param1);
  166.          }
  167.          param1.updateParent(this);
  168.       }
  169.    }
  170. }
  171.